package 线程的状态;


public class interruptTest1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            System.out.println("t1 sleep...");
            try {
                Thread.sleep(3000);//让t线程睡眠3s钟
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        t.start();
        Thread.sleep(1000);//让主线程睡眠1s钟,让t线程进入睡眠状态,再去打断
        t.interrupt();//打断正在睡眠的t线程
        //打断  使用wait,sleep,join 阻塞的线程  打断标记会被清空重置为false
        System.out.println("打断标记 : " + t.isInterrupted());
    }
}
